<!DOCTYPE html>
<!-- saved from url=(0046)https://www.cnblogs.com/iiiiher/p/8026555.html -->
<html lang="zh-cn"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="referrer" content="never">
<title>[k8s]jenkins配合kubernetes插件实现k8s集群构建的持续集成 - _毛台 - 博客园</title>
<link type="text/css" rel="stylesheet" href="./[k8s]jenkins配合kubernetes插件实现k8s集群构建的持续集成 - _毛台 - 博客园_files/blog-common.css">
<link id="MainCss" type="text/css" rel="stylesheet" href="./[k8s]jenkins配合kubernetes插件实现k8s集群构建的持续集成 - _毛台 - 博客园_files/bundle-SimpleBlue.css">
<link type="text/css" rel="stylesheet" href="./[k8s]jenkins配合kubernetes插件实现k8s集群构建的持续集成 - _毛台 - 博客园_files/243036.css">
<link id="mobile-style" media="only screen and (max-width: 767px)" type="text/css" rel="stylesheet" href="./[k8s]jenkins配合kubernetes插件实现k8s集群构建的持续集成 - _毛台 - 博客园_files/bundle-SimpleBlue-mobile.css">
<link title="RSS" type="application/rss+xml" rel="alternate" href="http://www.cnblogs.com/iiiiher/rss">
<link title="RSD" type="application/rsd+xml" rel="EditURI" href="http://www.cnblogs.com/iiiiher/rsd.xml">
<link type="application/wlwmanifest+xml" rel="wlwmanifest" href="http://www.cnblogs.com/iiiiher/wlwmanifest.xml">
<script async="" src="./[k8s]jenkins配合kubernetes插件实现k8s集群构建的持续集成 - _毛台 - 博客园_files/analytics.js.下载"></script><script src="./[k8s]jenkins配合kubernetes插件实现k8s集群构建的持续集成 - _毛台 - 博客园_files/jquery-2.2.0.min.js.下载"></script>
<script type="text/javascript">var currentBlogApp = 'iiiiher', cb_enable_mathjax=false;var isLogined=false;</script>
<script src="./[k8s]jenkins配合kubernetes插件实现k8s集群构建的持续集成 - _毛台 - 博客园_files/blog-common.js.下载" type="text/javascript"></script>
</head>
<body>
<a name="top"></a>
<!--PageBeginHtml Block Begin-->
<script src="./[k8s]jenkins配合kubernetes插件实现k8s集群构建的持续集成 - _毛台 - 博客园_files/buildCTable.js.下载" type="text/javascript"></script>
<!--PageBeginHtml Block End-->

<div id="home">
<div id="header">
	<div id="blogTitle">
		
<!--done-->
<div class="title"><a id="Header1_HeaderTitle" class="headermaintitle" href="http://www.cnblogs.com/iiiiher/">毛台</a></div>
<div class="subtitle">整齐胜于凌乱, 简单胜于复杂.</div>



		
	</div><!--end: blogTitle 博客的标题和副标题 -->
	<div id="navigator">
		
<ul id="navList">
<li id="nav_sitehome"><a id="blog_nav_sitehome" class="menu" href="http://www.cnblogs.com/">博客园</a></li>
<li id="nav_myhome"><a id="blog_nav_myhome" class="menu" href="http://www.cnblogs.com/iiiiher/">首页</a></li>
<li id="nav_newpost"></li>
<li id="nav_contact"></li>
<li id="nav_rss"><a id="blog_nav_rss" class="menu" href="http://www.cnblogs.com/iiiiher/rss">订阅</a>
<!--<a id="blog_nav_rss_image" class="aHeaderXML" href="http://www.cnblogs.com/iiiiher/rss"><img src="//www.cnblogs.com/images/xml.gif" alt="订阅" /></a>--></li>
<li id="nav_admin"><a id="blog_nav_admin" class="menu" rel="nofollow" href="https://i.cnblogs.com/">管理</a></li>
</ul>

		<div class="blogStats">
			
			<div id="blog_stats">
<!--done-->
随笔-385&nbsp;
文章-3&nbsp;
评论-4&nbsp;
</div>
			
		</div><!--end: blogStats -->
	</div><!--end: navigator 博客导航栏 -->
</div><!--end: header 头部 -->
<div id="main">
	<div id="mainContent">
	<div class="forFlow">
		
<div id="post_detail">
<!--done-->
<div id="topics">
	<div class="post">
		<h1 class="postTitle">
			<a id="cb_post_title_url" class="postTitle2" href="https://www.cnblogs.com/iiiiher/p/8026555.html">[k8s]jenkins配合kubernetes插件实现k8s集群构建的持续集成</a>
		</h1>
		<div class="clear"></div>
		<div class="postBody">
			<div style="clear:both"></div><div class="cnblogs_toc"><p style="text-align:right;margin:0;"><span style="float:left;">目录<a href="https://www.cnblogs.com/iiiiher/p/8026555.html#" title="系统根据文章中H1到H6标签自动生成文章目录">(?)</a></span><a href="https://www.cnblogs.com/iiiiher/p/8026555.html#" onclick="javascript:return openct(this);" title="展开">[+]</a></p><ol style="display:none;margin-left:14px;padding-left:14px;line-height:160%;"><li><a href="https://www.cnblogs.com/iiiiher/p/8026555.html#t0">k8s持续集成的一个思路</a></li><li><a href="https://www.cnblogs.com/iiiiher/p/8026555.html#t1">这篇文章思路</a></li><li><a href="https://www.cnblogs.com/iiiiher/p/8026555.html#t2">构建jnlp镜像的dockerfile</a></li><li><a href="https://www.cnblogs.com/iiiiher/p/8026555.html#t3">构建mvn352gitkubectl的镜像</a></li><li><a href="https://www.cnblogs.com/iiiiher/p/8026555.html#t4">测试jnlp镜像</a></li><li><a href="https://www.cnblogs.com/iiiiher/p/8026555.html#t5">tomcat java-helloworld项目</a></li><li><a href="https://www.cnblogs.com/iiiiher/p/8026555.html#t6">配置tomcat项目</a></li><li><a href="https://www.cnblogs.com/iiiiher/p/8026555.html#t7">k8s集群容器化tomcat项目</a></li><li><a href="https://www.cnblogs.com/iiiiher/p/8026555.html#t8">接下来需要手动编译确保项目通过集成测试可成功编译功能测试部署tomcat后可访问</a></li></ol></div><div style="clear:both"><br></div><div id="cnblogs_post_body" class="blogpost-body cnblogs-markdown"><p><a href="http://blog.chenmiao.cf/2016/12/28/gitlab+kubernetes+docker+jenkins+harbor%E6%90%AD%E5%BB%BA%E6%8C%81%E7%BB%AD%E4%BA%A4%E4%BB%98%E7%B3%BB%E7%BB%9F/#harbor">另一个结合harbor自动构建镜像的思路: 即code+baseimage一体的方案</a></p>
<pre><code class="hljs markdown"><span class="hljs-bullet">- </span>程序员将代码提交到代码仓库gitlab
<span class="hljs-bullet">- </span>钩子触发jenkins master启动一次构建
<span class="hljs-bullet">- </span>jenkins master从k8s申请一个jenkins slave编译容器
<span class="hljs-bullet">- </span>在容器内编译完成以后，获得最终产物
<span class="hljs-bullet">- </span>将最终产物通过dockerfile生成生产部署镜像（这里省略了测试，其实部署镜像需要测试通过）
<span class="hljs-bullet">- </span>将生产镜像推送到harbor镜像仓库
<span class="hljs-bullet">- </span>jenkins slave生命周期结束，k8s销毁slave容器
<span class="hljs-bullet">- </span>一次构建完成</code></pre>
<h2 id="k8s持续集成的一个思路"><a name="t0"></a>k8s持续集成的一个思路:</h2>
<p>这里要说的是部署部分<br>
<img src="./[k8s]jenkins配合kubernetes插件实现k8s集群构建的持续集成 - _毛台 - 博客园_files/9e792b8fgy1fmdrltnqb6j20lr0b9q3k.jpg"><br>
<img src="./[k8s]jenkins配合kubernetes插件实现k8s集群构建的持续集成 - _毛台 - 博客园_files/9e792b8fgy1fmdrn63bxwj216h0dk4e1.jpg"></p>
<p>注: 这只是一个持续集成思想.本篇按照这个思想来搞,在我的环境里我为了速度快当然还有别的因素我用这种方案,用的很6.<br>
其他思路:</p>
<ul>
<li>可以将code+image打在一起做升级</li>
<li>可以rbac+环境+ns+supervisor 每个开发一个环境这样搞<br>
后面我抽空一一实现下.</li>
</ul>
<h2 id="这篇文章思路"><a name="t1"></a>这篇文章思路:</h2>
<p>手动构建war包(集成测试)--&gt;本地tomcat测试通过(功能测试)--&gt;k8s容器化tomcat(pv+deploy+svc+ingress)--&gt;将war包拖入k8s的tomcat测试.</p>
<p>jenkins jnlp镜像构建(mvn+git+kubectl)-&gt; jnlp镜像测试,确保可被server动态调度--&gt;配置war包的pipeline测试.</p>
<p>注: 本篇jenkins server部署在vm上,非docker部署,jenkins-jnlp-slave是容器化自动创建的.<br>
其他内容参考: 容器ci索引: <a href="http://www.cnblogs.com/iiiiher/p/8026689.html" class="uri">http://www.cnblogs.com/iiiiher/p/8026689.html</a></p>
<h2 id="构建jnlp镜像的dockerfile"><a name="t2"></a>构建jnlp镜像的dockerfile</h2>
<ul>
<li>准备dockerfile所需文件</li>
</ul>
<pre><code class="hljs dos">git clone https://github.com/jenkinsci/docker-jnlp-slave.git
<span class="hljs-built_in">cd</span> docker-jnlp-slave

$ ls
Dockerfile  jenkins-slave  kubectl  README.<span class="hljs-built_in">md</span>
</code></pre>
<h2 id="构建mvn3.5.2gitkubectl的镜像"><a name="t3"></a>构建mvn3.5.2+git+kubectl的镜像</h2>
<p>基于jenkinsci/slave:alpine的基础镜像<br>
参考: <a href="https://github.com/jenkinsci/docker-slave/blob/master/Dockerfile" class="uri">https://github.com/jenkinsci/docker-slave/blob/master/Dockerfile</a><br>
<a href="https://github.com/jenkinsci/docker-jnlp-slave/blob/master/Dockerfile" class="uri">https://github.com/jenkinsci/docker-jnlp-slave/blob/master/Dockerfile</a><br>
<a href="https://hub.docker.com/r/jenkinsci/slave/tags/" class="uri">https://hub.docker.com/r/jenkinsci/slave/tags/</a></p>
<p>alpine-git安装参考:<br>
<a href="https://hub.docker.com/r/alpine/git/~/dockerfile/" class="uri">https://hub.docker.com/r/alpine/git/~/dockerfile/</a></p>
<pre><code class="hljs sql">$ cat Dockerfile 
FROM jenkinsci/slave:alpine

USER root
RUN apk add <span class="hljs-comment">--no-cache curl tar bash</span>

## <span class="hljs-keyword">Install</span> Maven
ARG MAVEN_VERSION=<span class="hljs-number">3.5</span><span class="hljs-number">.2</span>
ARG USER_HOME_DIR=<span class="hljs-string">"/root"</span>
ARG <span class="hljs-keyword">SHA</span>=<span class="hljs-number">707</span>b1f6e390a65bde4af4cdaf2a24d45fc19a6ded00fff02e91626e3e42ceaff
ARG BASE_URL=https://apache.osuosl.org/maven/maven<span class="hljs-number">-3</span>/${MAVEN_VERSION}/binaries

RUN mkdir -<span class="hljs-keyword">p</span> /usr/<span class="hljs-keyword">share</span>/maven /usr/<span class="hljs-keyword">share</span>/maven/<span class="hljs-keyword">ref</span> \
  &amp;&amp; curl -fsSL -o /tmp/apache-maven.tar.gz ${BASE_URL}/apache-maven-${MAVEN_VERSION}-<span class="hljs-keyword">bin</span>.tar.gz \
  &amp;&amp; echo <span class="hljs-string">"${SHA}  /tmp/apache-maven.tar.gz"</span> | sha256sum -<span class="hljs-keyword">c</span> - \
  &amp;&amp; tar -xzf /tmp/apache-maven.tar.gz -<span class="hljs-keyword">C</span> /usr/<span class="hljs-keyword">share</span>/maven <span class="hljs-comment">--strip-components=1 \</span>
  &amp;&amp; rm -<span class="hljs-keyword">f</span> /tmp/apache-maven.tar.gz \
  &amp;&amp; <span class="hljs-keyword">ln</span> -s /usr/<span class="hljs-keyword">share</span>/maven/<span class="hljs-keyword">bin</span>/mvn /usr/<span class="hljs-keyword">bin</span>/mvn \
  &amp;&amp; apk <span class="hljs-comment">--update add git openssh \</span>
  &amp;&amp; rm -rf /<span class="hljs-keyword">var</span>/lib/apt/lists<span class="hljs-comment">/* \
  &amp;&amp; rm /var/cache/apk/* \
  &amp;&amp; mkdir /src /target \
  &amp;&amp; chown jenkins.jenkins /src /target

ENV MAVEN_HOME /usr/share/maven
ENV MAVEN_CONFIG "$USER_HOME_DIR/.m2"

# install kubectl
COPY kubectl /usr/local/bin/kubectl

## install jenkins-slave
COPY jenkins-slave /usr/local/bin/jenkins-slave
USER jenkins
WORKDIR /home/jenkins
ENTRYPOINT ["jenkins-slave"]</span></code></pre>
<p>镜像已可以从dockerhub下载:</p>
<pre><code class="hljs groovy">docker pull lanny/mvn-git-kubectl-<span class="hljs-string">jnlp:</span><span class="hljs-number">3.5</span><span class="hljs-number">.2</span></code></pre>
<h2 id="测试jnlp镜像"><a name="t4"></a>测试jnlp镜像</h2>
<p>主要看他能否用jenkins-server动态调用跑起来<br>
当然首先安装jenkins kubernetes插件,新建一朵云:<br>
参考: <a href="http://www.cnblogs.com/iiiiher/p/7979336.html" class="uri">http://www.cnblogs.com/iiiiher/p/7979336.html</a></p>
<p>配置项目: 选择pipeline script<br>
<img src="./[k8s]jenkins配合kubernetes插件实现k8s集群构建的持续集成 - _毛台 - 博客园_files/9e792b8fgy1fmdqxnkwjoj20k00543yj.jpg"></p>
<pre><code class="hljs python">podTemplate(name: <span class="hljs-string">'maotai-dev'</span>, cloud: <span class="hljs-string">'kubernetes'</span>,
  namespace: <span class="hljs-string">'kube-public'</span>, label: <span class="hljs-string">'maotai-dev'</span>,
  serviceAccount: <span class="hljs-string">'default'</span>, containers: [
  containerTemplate(
      name: <span class="hljs-string">'jnlp'</span>,
      image: <span class="hljs-string">'lanny/mvn-git-kubectl-jnlp:3.5.2'</span>,
      args: <span class="hljs-string">'${computer.jnlpmac} ${computer.name}'</span>,
      ttyEnabled: true,
      privileged: false,
      alwaysPullImage: false)
  ],
) {

  node(<span class="hljs-string">'maotai-dev'</span>) {
    stage(<span class="hljs-string">'git-clone'</span>) {
      container(<span class="hljs-string">'jnlp'</span>) {
          sh <span class="hljs-string">"""
          date +%F;
          sleep 30;
          """</span>
      }
    }
  }
}
</code></pre>
<p>点击构建--&gt;显示构建成功<br>
<img src="./[k8s]jenkins配合kubernetes插件实现k8s集群构建的持续集成 - _毛台 - 博客园_files/9e792b8fgy1fmdqx2pkdhj20pt0hr3zs.jpg"><br>
构建成功后jnlp镜像随着构建结束自动删除.</p>
<h2 id="tomcat-java-helloworld项目"><a name="t5"></a>tomcat java-helloworld项目</h2>
<p>kubernetes插件的pipeline使用:<br>
参考:<br>
<a href="https://github.com/jenkinsci/kubernetes-plugin" class="uri">https://github.com/jenkinsci/kubernetes-plugin</a><br>
<a href="https://help.aliyun.com/document_detail/56336.html?spm=5176.doc56336.6.851.wAqCzu" class="uri">https://help.aliyun.com/document_detail/56336.html?spm=5176.doc56336.6.851.wAqCzu</a></p>
<p>javahelloworld代码: <a href="https://github.com/lannyMa/trucks" class="uri">https://github.com/lannyMa/trucks</a> ,构建可形成helloworld的war包.可以部署在tomcat用于测试.</p>
<p>jenkins项目配置: 新建项目 test-pipeline</p>
<pre><code class="hljs python">podTemplate(name: <span class="hljs-string">'maotai-dev'</span>, cloud: <span class="hljs-string">'kubernetes'</span>,
  namespace: <span class="hljs-string">'kube-public'</span>, label: <span class="hljs-string">'maotai-dev'</span>,
  serviceAccount: <span class="hljs-string">'default'</span>, containers: [
  containerTemplate(
      name: <span class="hljs-string">'jnlp'</span>,
      image: <span class="hljs-string">'lanny/mvn-git-kubectl-jnlp:3.5.2'</span>,
      args: <span class="hljs-string">'${computer.jnlpmac} ${computer.name}'</span>,
      ttyEnabled: true,
      privileged: false,
      alwaysPullImage: false)
  ],
  volumes: [
    persistentVolumeClaim(mountPath: <span class="hljs-string">'/tmp/'</span>, claimName: <span class="hljs-string">'spring-pvc'</span>)
  ]) {
  node(<span class="hljs-string">'maotai-dev'</span>) {
    stage(<span class="hljs-string">'git-clone'</span>) {
      container(<span class="hljs-string">'jnlp'</span>) {
          sh <span class="hljs-string">"""
          git clone https://github.com/lannyMa/trucks.git
          """</span>
      }
    }

    stage(<span class="hljs-string">'mvn-package'</span>) {
      container(<span class="hljs-string">'jnlp'</span>) {
          sh <span class="hljs-string">"""
          cd trucks &amp;&amp; mvn clean package &amp;&amp; cp -rpf target/*.war /tmp/
          """</span>
      }
    }

    stage(<span class="hljs-string">'restart'</span>) {
      container(<span class="hljs-string">'jnlp'</span>) {
          sh <span class="hljs-string">"""
          pod_name=`kubectl -s 192.168.x.x:8080 -n kube-public get pods -l name=maotai-dev -o name | cut -d"/" -f2`
          kubectl -s kube-apiserver-http.kube-public -n kube-public delete pod \$pod_name
          """</span>
      }
    }
  }
}
</code></pre>
<h2 id="配置tomcat项目"><a name="t6"></a>配置tomcat项目</h2>
<p>tomcat-pvc.yaml #前提是配置好stroragecalss: 参考: <a href="http://www.cnblogs.com/iiiiher/p/7988803.html" class="uri">http://www.cnblogs.com/iiiiher/p/7988803.html</a></p>
<pre><code class="hljs dts"><span class="hljs-symbol">kind:</span> PersistentVolumeClaim
<span class="hljs-symbol">apiVersion:</span> v1
<span class="hljs-symbol">metadata:</span>
<span class="hljs-symbol">  name:</span> spring-pvc
<span class="hljs-symbol">  namespace:</span> kube-public
<span class="hljs-symbol">spec:</span>
<span class="hljs-symbol">  storageClassName:</span> <span class="hljs-string">"managed-nfs-storage"</span>
<span class="hljs-symbol">  accessModes:</span>
    - ReadOnlyMany
<span class="hljs-symbol">  resources:</span>
<span class="hljs-symbol">    requests:</span>
<span class="hljs-symbol">      storage:</span> <span class="hljs-number">100</span>Mi</code></pre>
<p>tomcat-deploy.yaml</p>
<pre><code class="hljs yaml"><span class="hljs-attr">apiVersion:</span> extensions/v1beta1
<span class="hljs-attr">kind:</span> Deployment
<span class="hljs-attr">metadata:</span>
<span class="hljs-attr">  name:</span> spring
<span class="hljs-attr">  namespace:</span> kube-public
<span class="hljs-attr">spec:</span>
<span class="hljs-attr">  replicas:</span> <span class="hljs-number">1</span>
<span class="hljs-attr">  template:</span>
<span class="hljs-attr">    metadata:</span>
<span class="hljs-attr">      labels:</span>
<span class="hljs-attr">        name:</span> spring
<span class="hljs-attr">        name:</span> maotai-dev  <span class="hljs-comment">#这里标签设置需注意,因为jenkins配置kubectl的stage时需要根据标签过滤重启它: kubectl -s 192.168.x.x:8080 -n kube-public get pods -l name=spring -o name | cut -d"/" -f2</span>
<span class="hljs-attr">    spec:</span>
<span class="hljs-attr">      containers:</span>
<span class="hljs-attr">      - name:</span> spring
<span class="hljs-attr">        image:</span> tomcat:latest
<span class="hljs-attr">        imagePullPolicy:</span> IfNotPresent
<span class="hljs-attr">        ports:</span>
<span class="hljs-attr">        - name:</span> web
<span class="hljs-attr">          containerPort:</span> <span class="hljs-number">8080</span>
<span class="hljs-attr">        volumeMounts:</span>
<span class="hljs-attr">        - mountPath:</span> /usr/local/tomcat/webapps
<span class="hljs-attr">          name:</span> spring-folder
<span class="hljs-attr">      volumes:</span>
<span class="hljs-attr">      - name:</span> spring-folder
<span class="hljs-attr">        persistentVolumeClaim:</span>
<span class="hljs-attr">          claimName:</span> spring-pvc</code></pre>
<p>执行成功:<br>
<img src="./[k8s]jenkins配合kubernetes插件实现k8s集群构建的持续集成 - _毛台 - 博客园_files/9e792b8fgy1fmdrkgc62wj20oc0l7jvk.jpg"></p>
<h2 id="k8s集群容器化tomcat项目"><a name="t7"></a>k8s集群容器化tomcat项目</h2>
<ul>
<li>容器化tomcat项目: 配置k8s集群的tomcat 包含了 pvc+deploy+svc+ingress</li>
<li>做法:</li>
<li>先手动编译项目,本次tomcat测试通过</li>
<li>集成到k8s集群的tomcat,测试,确保项目可以正常运行</li>
</ul>
<p>tomcat-svc.yaml</p>
<pre><code class="hljs yaml"><span class="hljs-attr">apiVersion:</span> v1
<span class="hljs-attr">kind:</span> Service
<span class="hljs-attr">metadata:</span>
<span class="hljs-attr">  name:</span> spring
<span class="hljs-attr">  namespace:</span> kube-public
<span class="hljs-attr">  labels:</span>
<span class="hljs-attr">    name:</span> spring
<span class="hljs-attr">spec:</span>
<span class="hljs-attr">  ports:</span>
<span class="hljs-attr">    - name:</span> web
<span class="hljs-attr">      port:</span> <span class="hljs-number">8080</span>
<span class="hljs-attr">      targetPort:</span> web
<span class="hljs-attr">  selector:</span>
<span class="hljs-attr">    name:</span> spring
</code></pre>
<p>tomcat-ingress.yaml #前提是已配置好了ingress,nginx-ingress配置参考:<a href="http://www.cnblogs.com/iiiiher/p/8006801.html" class="uri">http://www.cnblogs.com/iiiiher/p/8006801.html</a></p>
<pre><code class="hljs yaml"><span class="hljs-attr">apiVersion:</span> extensions/v1beta1
<span class="hljs-attr">kind:</span> Ingress
<span class="hljs-attr">metadata:</span>
<span class="hljs-attr">  name:</span> spring
<span class="hljs-attr">  namespace:</span> kube-public
<span class="hljs-attr">spec:</span>
<span class="hljs-attr">  rules:</span>
<span class="hljs-attr">  - host:</span> spring.maotai.net
<span class="hljs-attr">    http:</span>
<span class="hljs-attr">      paths:</span>
<span class="hljs-attr">      - path:</span> /
<span class="hljs-attr">        backend:</span>
<span class="hljs-attr">          serviceName:</span> spring
<span class="hljs-attr">          servicePort:</span> web
</code></pre>
<p>创建好后确保能够访问:<br>
<img src="./[k8s]jenkins配合kubernetes插件实现k8s集群构建的持续集成 - _毛台 - 博客园_files/9e792b8fgy1fmdr5j9h9gj20eh03ymx1.jpg"></p>
<h2 id="接下来需要手动编译确保项目通过集成测试可成功编译功能测试部署tomcat后可访问"><a name="t8"></a>接下来需要手动编译,确保项目通过集成测试(可成功编译),功能测试(部署tomcat后可访问)</h2>
<p>项目代码: <a href="https://github.com/lannyMa/trucks.git" class="uri">https://github.com/lannyMa/trucks.git</a><br>
mvn配置改源等参考: <a href="https://github.com/lannyMa/java-helloword.git" class="uri">https://github.com/lannyMa/java-helloword.git</a></p>
<p>确保没问题后将war包放到上一步创建的pv里.我的是nfs,直接到nfs-server上把war包托上去,然后重启tomcat,测试效果.</p>
</div><div id="MySignature"></div>
<div class="clear"></div>
<div id="blog_post_info_block">
<div id="BlogPostCategory"></div>
<div id="EntryTag"></div>
<div id="blog_post_info"><div id="green_channel">
        <a href="javascript:void(0);" id="green_channel_digg" onclick="DiggIt(8026555,cb_blogId,1);green_channel_success(this,&#39;谢谢推荐！&#39;);">好文要顶</a>
            <a id="green_channel_follow" onclick="follow(&#39;4032493b-d251-e511-b908-9dcfd8948a71&#39;);" href="javascript:void(0);">关注我</a>
    <a id="green_channel_favorite" onclick="AddToWz(cb_entryId);return false;" href="javascript:void(0);">收藏该文</a>
    <a id="green_channel_weibo" href="javascript:void(0);" title="分享至新浪微博" onclick="ShareToTsina()"><img src="./[k8s]jenkins配合kubernetes插件实现k8s集群构建的持续集成 - _毛台 - 博客园_files/icon_weibo_24.png" alt=""></a>
    <a id="green_channel_wechat" href="javascript:void(0);" title="分享至微信" onclick="shareOnWechat()"><img src="./[k8s]jenkins配合kubernetes插件实现k8s集群构建的持续集成 - _毛台 - 博客园_files/wechat.png" alt=""></a>
</div>
<div id="author_profile">
    <div id="author_profile_info" class="author_profile_info">
            <a href="http://home.cnblogs.com/u/iiiiher/" target="_blank"><img src="./[k8s]jenkins配合kubernetes插件实现k8s集群构建的持续集成 - _毛台 - 博客园_files/20160928081207.png" class="author_avatar" alt=""></a>
        <div id="author_profile_detail" class="author_profile_info">
            <a href="http://home.cnblogs.com/u/iiiiher/">_毛台</a><br>
            <a href="http://home.cnblogs.com/u/iiiiher/followees">关注 - 4</a><br>
            <a href="http://home.cnblogs.com/u/iiiiher/followers">粉丝 - 9</a>
        </div>
    </div>
    <div class="clear"></div>
    <div id="author_profile_honor"></div>
    <div id="author_profile_follow">
                <a href="javascript:void(0);" onclick="follow(&#39;4032493b-d251-e511-b908-9dcfd8948a71&#39;);return false;">+加关注</a>
    </div>
</div>
<div id="div_digg">
    <div class="diggit" onclick="votePost(8026555,&#39;Digg&#39;)">
        <span class="diggnum" id="digg_count">0</span>
    </div>
    <div class="buryit" onclick="votePost(8026555,&#39;Bury&#39;)">
        <span class="burynum" id="bury_count">0</span>
    </div>
    <div class="clear"></div>
    <div class="diggword" id="digg_tips">
    </div>
</div>
<script type="text/javascript">
    currentDiggType = 0;
</script></div>
<div class="clear"></div>
<div id="post_next_prev"><a href="http://www.cnblogs.com/iiiiher/p/8021621.html" class="p_n_p_prefix">« </a> 上一篇：<a href="http://www.cnblogs.com/iiiiher/p/8021621.html" title="发布于2017-12-11 09:36">[svc]jq神器使用</a><br><a href="http://www.cnblogs.com/iiiiher/p/8026689.html" class="p_n_p_prefix">» </a> 下一篇：<a href="http://www.cnblogs.com/iiiiher/p/8026689.html" title="发布于2017-12-12 10:44">[ci]容器ci索引</a><br></div>
</div>


		</div>
		<div class="postDesc">posted @ <span id="post-date">2017-12-12 10:20</span> <a href="http://www.cnblogs.com/iiiiher/">_毛台</a> 阅读(<span id="post_view_count">585</span>) 评论(<span id="post_comment_count">0</span>)  <a href="https://i.cnblogs.com/EditPosts.aspx?postid=8026555" rel="nofollow">编辑</a> <a href="https://www.cnblogs.com/iiiiher/p/8026555.html#" onclick="AddToWz(8026555);return false;">收藏</a></div>
	</div>
	<script src="./[k8s]jenkins配合kubernetes插件实现k8s集群构建的持续集成 - _毛台 - 博客园_files/highlight.min.js.下载"></script><script>markdown_highlight();</script><script type="text/javascript">var allowComments=true,cb_blogId=243036,cb_entryId=8026555,cb_blogApp=currentBlogApp,cb_blogUserGuid='4032493b-d251-e511-b908-9dcfd8948a71',cb_entryCreatedDate='2017/12/12 10:20:00';loadViewCount(cb_entryId);var cb_postType=1;</script>
	
</div><!--end: topics 文章、评论容器-->
</div><a name="!comments"></a><div id="blog-comments-placeholder"></div><script type="text/javascript">var commentManager = new blogCommentManager();commentManager.renderComments(0);</script>
<div id="comment_form" class="commentform">
<a name="commentform"></a>
<div id="divCommentShow"></div>
<div id="comment_nav"><span id="span_refresh_tips"></span><a href="javascript:void(0);" onclick="return RefreshCommentList();" id="lnk_RefreshComments" runat="server" clientidmode="Static">刷新评论</a><a href="https://www.cnblogs.com/iiiiher/p/8026555.html#" onclick="return RefreshPage();">刷新页面</a><a href="https://www.cnblogs.com/iiiiher/p/8026555.html#top">返回顶部</a></div>
<div id="comment_form_container"><div class="login_tips">注册用户登录后才能发表评论，请 <a rel="nofollow" href="javascript:void(0);" class="underline" onclick="return login(&#39;commentform&#39;);">登录</a> 或 <a rel="nofollow" href="javascript:void(0);" class="underline" onclick="return register();">注册</a>，<a href="http://www.cnblogs.com/">访问</a>网站首页。</div></div>
<div class="ad_text_commentbox" id="ad_text_under_commentbox"></div>
<div id="ad_t2"><a href="http://www.ucancode.com/index.htm" target="_blank">【推荐】超50万VC++源码: 大型组态工控、电力仿真CAD与GIS源码库！</a><br><a href="https://www.yunqi2050.com/" target="_blank">【活动】2050 大会 - 年青人因科技而团聚（5.26-5.27 杭州·云栖小镇）</a><br><a href="http://clickc.admaster.com.cn/c/a105960,b2436452,c1705,i0,m101,8a1,8b2,h" target="_blank" onclick="ga(&#39;send&#39;, &#39;event&#39;, &#39;Link&#39;, &#39;click&#39;, &#39;T2-DevCloud&#39;)">【推荐】华为云7大明星产品0元免费使用</a><br><a href="https://cloud.tencent.com/product/tac?fromSource=gwzcw.926333.926333.926333" target="_blank" onclick="ga(&#39;send&#39;, &#39;event&#39;, &#39;Link&#39;, &#39;click&#39;, &#39;T2-腾讯云&#39;)">【推荐】腾讯云如何降低移动开发成本</a><br><a href="http://challenge.xfyun.cn/?ch=bk" target="_blank" onclick="ga(&#39;send&#39;, &#39;event&#39;, &#39;Link&#39;, &#39;click&#39;, &#39;T2-xfyun&#39;)">【大赛】2018首届“顶天立地”AI开发者大赛</a><br></div>
<div id="opt_under_post"></div>
<div id="cnblogs_c1" class="c_ad_block"><a onclick="ga(&#39;send&#39;, &#39;event&#39;, &#39;Link&#39;, &#39;click&#39;, &#39;C1&#39;);" href="https://cloud.tencent.com/solution/la?fromSource=gwzcw.926335.926335.926335" target="_blank"><img width="300" height="250" src="./[k8s]jenkins配合kubernetes插件实现k8s集群构建的持续集成 - _毛台 - 博客园_files/24442-20180520213658559-918592692.jpg" alt="腾讯云0518"></a></div>
<div id="under_post_news"><div class="itnews c_ad_block"><b>最新IT新闻</b>:<br> ·  <a href="https://news.cnblogs.com/n/597456/" target="_blank">中兴通讯发布公告：A股继续停牌 控股股东增持</a><br> ·  <a href="https://news.cnblogs.com/n/597455/" target="_blank">50项技术让人延寿40年！一图看清史上最牛的发明</a><br> ·  <a href="https://news.cnblogs.com/n/597453/" target="_blank">视频揭示：艾滋病病毒如何“感染”细胞</a><br> ·  <a href="https://news.cnblogs.com/n/597452/" target="_blank">马斯克将创办新闻和记者信誉点评网站Pravda</a><br> ·  <a href="https://news.cnblogs.com/n/597454/" target="_blank">腾讯“赛马”：既当运动员又当裁判官</a><br>» <a href="http://news.cnblogs.com/" title="IT新闻" target="_blank">更多新闻...</a></div></div>
<div id="cnblogs_c2" class="c_ad_block"><a href="http://click.aliyun.com/m/34770/" target="_blank"><img src="./[k8s]jenkins配合kubernetes插件实现k8s集群构建的持续集成 - _毛台 - 博客园_files/TB1gBPhgZLJ8KJjy0FnXXcFDpXa-468-60.jpg" alt="" style="width: 468px; height: 60px;"></a></div>
<div id="under_post_kb"><div class="itnews c_ad_block" id="kb_block"><b>最新知识库文章</b>:<br><div id="kb_recent"> ·  <a href="http://kb.cnblogs.com/page/576411/" target="_blank">你可以把编程当做一项托付终身的职业</a><br> ·  <a href="http://kb.cnblogs.com/page/596164/" target="_blank">评审的艺术——谈谈现实中的代码评审</a><br> ·  <a href="http://kb.cnblogs.com/page/577233/" target="_blank">如何高效学习</a><br> ·  <a href="http://kb.cnblogs.com/page/578689/" target="_blank">如何成为优秀的程序员？</a><br> ·  <a href="http://kb.cnblogs.com/page/594930/" target="_blank">菜鸟工程师的超神之路 -- 从校园到职场</a><br></div>» <a href="http://kb.cnblogs.com/" target="_blank">更多知识库文章...</a></div></div>
<div id="HistoryToday" class="c_ad_block"></div>
<script type="text/javascript">
    fixPostBody();
    setTimeout(function () { incrementViewCount(cb_entryId); }, 50);
    deliverAdT2();
    deliverAdC1();
    deliverAdC2();    
    loadNewsAndKb();
    loadBlogSignature();
    LoadPostInfoBlock(cb_blogId, cb_entryId, cb_blogApp, cb_blogUserGuid);
    GetPrevNextPost(cb_entryId, cb_blogId, cb_entryCreatedDate, cb_postType);
    loadOptUnderPost();
    GetHistoryToday(cb_blogId, cb_blogApp, cb_entryCreatedDate);   
</script>
</div>


	</div><!--end: forFlow -->
	</div><!--end: mainContent 主体内容容器-->

	<div id="sideBar">
		<div id="sideBarMain">
			
<!--done-->
<div class="newsItem">
<h3 class="catListTitle">公告</h3>
	<div id="blog-news"><div id="profile_block">昵称：<a href="https://home.cnblogs.com/u/iiiiher/">_毛台</a><br>园龄：<a href="https://home.cnblogs.com/u/iiiiher/" title="入园时间：2015-09-03">2年8个月</a><br>粉丝：<a href="https://home.cnblogs.com/u/iiiiher/followers/">9</a><br>关注：<a href="https://home.cnblogs.com/u/iiiiher/followees/">4</a><div id="p_b_follow"><a href="javascript:void(0);" onclick="follow(&#39;4032493b-d251-e511-b908-9dcfd8948a71&#39;)">+加关注</a></div><script>getFollowStatus('4032493b-d251-e511-b908-9dcfd8948a71')</script></div></div><script type="text/javascript">loadBlogNews();</script>
</div>

			<div id="calendar"><div id="blog-calendar" style="display:none"></div><script type="text/javascript">loadBlogDefaultCalendar();</script></div>
			
			<div id="leftcontentcontainer">
				<div id="blog-sidecolumn"><div id="sidebar_search" class="sidebar-block">
<div id="sidebar_search" class="mySearch">
<h3 class="catListTitle">搜索</h3>
<div id="sidebar_search_box">
<div id="widget_my_zzk" class="div_my_zzk"><input type="text" id="q" onkeydown="return zzk_go_enter(event);" class="input_my_zzk">&nbsp;<input onclick="zzk_go()" type="button" value="找找看" id="btnZzk" class="btn_my_zzk"></div>

</div>
</div>

</div><div id="sidebar_shortcut" class="sidebar-block">
<div class="catListLink">
<h3 class="catListTitle">常用链接</h3>
<ul>
<li><a href="http://www.cnblogs.com/iiiiher/p/" title="我的博客的随笔列表">我的随笔</a></li><li><a href="http://www.cnblogs.com/iiiiher/MyComments.html" title="我发表过的评论列表">我的评论</a></li><li><a href="http://www.cnblogs.com/iiiiher/OtherPosts.html" title="我评论过的随笔列表">我的参与</a></li><li><a href="http://www.cnblogs.com/iiiiher/RecentComments.html" title="我的博客的评论列表">最新评论</a></li><li><a href="http://www.cnblogs.com/iiiiher/tag/" title="我的博客的标签列表">我的标签</a></li>
</ul>
<div id="itemListLin_con" style="display:none;">
<ul>

</ul>
</div>
</div></div><div id="sidebar_categories">
<div class="catList">
<h3 class="catListTitle">友链</h3>

<ul>

<li><a id="CatList_LinkList_0_Link_0" href="https://lannyma.blog.51cto.com/" rel="nofollow" target="_blank">51cto</a> </li>

<li><a id="CatList_LinkList_0_Link_1" href="https://www.52devops.com/" rel="nofollow">52devops</a> </li>

<li><a id="CatList_LinkList_0_Link_2" href="https://blog.51cto.com/yangrong" rel="nofollow">yangrong</a> </li>

<li><a id="CatList_LinkList_0_Link_3" href="https://i.youku.com/imaxiaolang" rel="nofollow" target="_blank">youku</a> </li>

<li><a id="CatList_LinkList_0_Link_4" href="https://www.z-dig.com/" rel="nofollow">卑鄙的我</a> </li>

<li><a id="CatList_LinkList_0_Link_5" href="https://www.cnblogs.com/clsn/" rel="nofollow">惨绿少年</a> </li>

<li><a id="CatList_LinkList_0_Link_6" href="https://blog.51cto.com/freeloda" rel="nofollow">陈明乾</a> </li>

<li><a id="CatList_LinkList_0_Link_7" href="https://www.cnblogs.com/chensiqiqi/" rel="nofollow">陈思齐</a> </li>

<li><a id="CatList_LinkList_0_Link_8" href="https://www.cnblogs.com/qiyeboy" rel="nofollow">七夜的故事(Python爬虫开发与项目实战作者)</a> </li>

</ul>

</div>

</div></div><script type="text/javascript">loadBlogSideColumn();</script>
			</div>
			
		</div><!--end: sideBarMain -->
	</div><!--end: sideBar 侧边栏容器 -->
	<div class="clear"></div>
	</div><!--end: main -->
	<div class="clear"></div>
	<div id="footer">
		
<!--done-->
Copyright ©2018 _毛台
	</div><!--end: footer -->
</div><!--end: home 自定义的最大容器 -->
<!--PageEndHtml Block Begin-->
<script type="text/javascript">
    var setMyBlog = {
        setCodeRow: function(){
            // 代码行号显示
            var pre = $("pre.sourceCode"); //选中需要更改的部分
            if(pre && pre.length){
                pre.each(function() {
                    var item = $(this);
                    var lang = item.attr("class").split(" ")[1]; //判断高亮的语言
                    item.html(item.html().replace(/<[^>]+>/g,"")); //将<pre>标签中的html标签去掉
                    item.removeClass().addClass("brush: " + lang +";"); //根据语言添加笔刷
                    SyntaxHighlighter.all();
                })
            }
        },
        setAtarget: function() {
            // 博客内的链接在新窗口打开
            $("#cnblogs_post_body a").each(function(){
                this.target = "_blank";
            })
        },
        runAll: function() {
            /* 运行所有方法
             * setAtarget() 博客园内标签新窗口打开
             * setContent() 设置目录
             * setCopyright() 设置版权信息
             * setCodeRow() 代码行号显示
             */
            this.setAtarget();
            this.setCodeRow();
        }
    }
    //setMyBlog.runAll();
</script>
<!--PageEndHtml Block End-->


</body></html>